package com.seckill.trade.controller;

import com.seckill.trade.domian.dto.PayOrderFormDTO;
import com.seckill.trade.domian.dto.PlaceOrderDTO;
import com.seckill.trade.domian.query.OrderRequestQuery;
import com.seckill.trade.domian.vo.OrderConfirmVO;
import com.seckill.trade.domian.vo.PlaceOrderResultVO;
import com.seckill.trade.service.IOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author zsc
 * @since 2025-05-20
 */
@RestController
@RequestMapping("/order")
@Api(tags = "订单相关接口")
public class OrderController {

    @Autowired
    private IOrderService orderService;

    //预下单
    @ApiOperation(value = "预下单")
    @PostMapping("/createOrder")
    public OrderConfirmVO createOrder(@RequestBody OrderRequestQuery orderRequestQuery){
       return orderService.createOrder(orderRequestQuery);
    }

    //下单
    @ApiOperation(value = "下单")
    @PostMapping("placeOrder")
    public PlaceOrderResultVO placeOrder(@RequestBody @Validated PlaceOrderDTO placeOrderDTO) {
        return orderService.placeOrder(placeOrderDTO);
    }

    //秒杀抢单
    @ApiOperation(value = "秒杀抢单")
    @PostMapping("/seckillOrder")
    public void seckillOrder(@RequestBody OrderRequestQuery orderRequestQuery){
        orderService.seckillOrder(orderRequestQuery);
    }

    //订单支付
    @ApiOperation(value = "订单支付")
    @PostMapping("/payOrder")
    public void payOrder(@RequestBody PayOrderFormDTO payOrderFormDTO){
        orderService.payOrder(payOrderFormDTO);
    }



}
